package com.bindatax.core.log.impl;

import com.bindatax.core.log.LogOutInterface;

import java.util.Properties;
import java.util.Set;

public abstract class BaseLogOut implements LogOutInterface {

    protected final static Properties _config = new Properties();

    public abstract String getType();
    @Override
    public void init(Properties logConfig) {
        if(logConfig == null || logConfig.size() == 0){
            return;
        }
        Set<Object> keys = logConfig.keySet();
        String type = getType()+".";
        for (Object key : keys){
            if(key.toString().startsWith(type)){
                _config.put(key,logConfig.get(key) );
            }
        }
        System.out.println( getType()+"实例配置项数量：" + _config.size());
    }

    // 获取当前调用者名
    protected String getInvokeName(String name){
        if(name != null){
            return name;
        }
        return Thread.currentThread().getStackTrace()[3].getClassName();
    }

    public abstract void info(String msg);
    public abstract void info(String name,String msg);

    public abstract void info(String msg, Throwable t);
    public abstract void info(String name,String msg, Throwable t);

    public abstract void warn(String msg);
    public abstract void warn(String name,String msg);

    public abstract void warn(String msg, Throwable t);
    public abstract void warn(String name,String msg, Throwable t);

    public abstract void debug(String msg);
    public abstract void debug(String name,String msg);

    public abstract void debug(String msg, Throwable t);
    public abstract void debug(String name,String msg, Throwable t);

    public abstract void error(String msg);
    public abstract void error(String name,String msg);

    public abstract void error(String msg, Throwable t);
    public abstract void error(String name,String msg, Throwable t);
}
